<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="Bookmark" href="/favicon.ico">
		<link rel="Shortcut Icon" href="/favicon.ico" />
		<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
		<link rel="stylesheet" href="../lib/layui/css/layui.css">

		<title>新增管路员</title>
	</head>

	<body>
		<div class="page-container">
			<form id="addForm" class="layui-form" lay-filter="addForm">
				<input type="hidden" id="ftoken" name="token" />
				<input type="hidden" id="ftokenUserId" name="tokenUserId" />
				<input type="hidden" id="update_id" name="id" />
				<div class="layui-form-item">
					<label class="layui-form-label">登录名称</label>
					<div class="layui-input-block">
						<input id="userName" type="text" name="userName" lay-verify="userName" autocomplete="off" placeholder="清输入登录名称，长度不低于6位" class="layui-input">
					</div>
				</div>
				<div id="loginPwdDiv" class="layui-form-item">
					<label class="layui-form-label">登录密码</label>
					<div class="layui-input-block">
						<input id="loginPwd" type="password" name="loginPwd" lay-verify="loginPwd" autocomplete="off" placeholder="" class="layui-input">
					</div>
				</div>
				<div id="loginPwd2Div" class="layui-form-item">
					<label class="layui-form-label">确认密码</label>
					<div class="layui-input-block">
						<input id="loginPwd2" type="password" name="loginPwd2" lay-verify="loginPwd2" autocomplete="off" placeholder="" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邮箱地址</label>
					<div class="layui-input-block">
						<input id="email" type="text" name="email" lay-verify="email" autocomplete="off" placeholder="清输入联系邮箱地址" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">联系电话</label>
					<div class="layui-input-block">
						<input id="mobile" type="number" name="mobile" lay-verify="mobile" autocomplete="off" placeholder="清输入联系电话" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">登录状态</label>
					<div class="layui-input-block">
						<select id="status" name="status" lay-filter="status">
							<option value="1">正常</option>
							<option value="0">禁用</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item text-c">
					<button class="layui-btn" lay-submit="" lay-filter="btnSubmit">保存</button>
					<button class="layui-btn" type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</form>
		</div>
		<div id="pager" class="clearfix"></div>
		<!--_footer 作为公共模版分离出去-->
		<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
		<script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
		<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
		<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
		<!--/_footer 作为公共模版分离出去-->
		<script type="text/javascript" src="../lib/layui/layui.js"></script>
		<script type="text/javascript" src="../static/js/common.js"></script>
		<!--请在下方写此页面业务相关的脚本-->
		<script type="text/javascript">
			var update_id = parent.$("#update_id").val();
			$(function() {
				$("#update_id").val(update_id);
				$("#ftoken").val(token);
				$("#ftokenUserId").val(userId);

				if(update_id) {
					$("#loginPwdDiv").remove();
					$("#loginPwd2Div").remove();
					//回显数据
					var data = {
						"token": token,
						"tokenUserId": userId,
						"id": update_id
					};
					request_ajax("POST", admin_url + "/scaSysUser/suserInfo", data, function(result) {
						$("#userName").val(result.data.userName);
						$("#email").val(result.data.email);
						$("#mobile").val(result.data.mobile);
						$("#status").val(result.data.status);
					});
				}

			});

			layui.use(['form'], function() {
				var form = layui.form;
				//自定义验证规则
				form.verify({
					userName: function(value) {
						if(value.length < 6) {
							return '登录用户名长度不能少于6位';
						}
					},
					loginPwd: function(value) {
						if(value.length < 8) {
							return '登录密码长度不能少于8位';
						}
					},
					loginPwd2: function(value) {
						if($("#loginPwd").val() != value) {
							return '确认密码不正确';
						}
					}
				});

				//监听提交
				form.on('submit(btnSubmit)', function(e) {
					var url = admin_url + "/scaSysUser/addSysUser";
					if(update_id) {
						url = admin_url + "/scaSysUser/updSysUser";
					}
					request_ajax("POST", url, e.field, function(result) {
						layer.msg(result.msg, {
							time: 800,
							end: function() {
								var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(index); //再执行关闭   
								parent.tableReload();
							}
						});
					});
					return false;
				});

			});
		</script>
	</body>

</html>